<?php
        //Dialog box - defined in index
        //$this->renderPartial("_formDialog");

        //Confirmation dialog - defined in index
        //$this->renderPartial("_confirmationModalDialog");

	//CGridView
        $jsDelFunction = '
            openConfirmationModalDialog(
                \"Are you sure you want to delete <b>$data->name</b>?\",
                function(){
                    var url = \"'.$this->createUrl("roomtype/delete", array("id" => "xidx")).'\"
                    \$.getJSON(
                    url.replace(\"xidx\", \"$data->id\"),
                    function(data) {
                        if(data.errId) {

                        } else {
                            $.fn.yiiGridView.update(\"roomTypeForm-grid\");
                            closeConfirmationModalDialog();
                        }
                    }
                );}
            )
        ';
	$this->widget('zii.widgets.grid.CGridView', array(
		'id'=>'roomTypeForm-grid',
		'dataProvider'=>$model->search(),
                'filter'=>$model,
		'columns'=>array(
                    //name button
                    'name',
                    array(
                        'value' => 'CHtml::button("Edit", array("onclick" => "roomType_openForUpdate($data->id, \"$data->name\", \"roomTypeForm-grid\");")) . " " . CHtml::button("Delete", array("onclick" => "'.$jsDelFunction.'"))',
                        'type' => 'raw',
                        'htmlOptions'=>array('width' => '150'),
                    ),
                    /*array(
                        'class'=>'CButtonColumn',
                                'template'=>'{test}',
                                'buttons'=>array(
                                                'test'=>array(
                                                        'label'=>'AAA',
                                                        'url'=>'"#"',
                                                        'click'=>'function(){var rowIdx=$(this).closest("tr").attr("sectionRowIndex");var rowId=$("#"+$(this).closest("div.grid-view").attr("id")+" > div.keys > span:eq("+rowIdx+")").text();alert(rowId);}',
                                                ),
                        )
                    ),
                     * 
                     */
		),
	));

	//add new room type
        echo CHtml::button('Create New Room Type', array(
           'onclick'=>'roomType_openForCreate("roomTypeForm-grid"); return false;',
        ));
?>